package com.sunshine.cloud;

import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;

import java.io.IOException;

/**
 * TestHttpClient class
 *
 * @author WeiHong
 * @date 2018/11/9
 */
public class TestHttpClient {
    public static void main(String[] args) throws IOException {
        // 创建默认的HttpClient
        CloseableHttpClient httpclient = HttpClients.createDefault();
        for (int i = 0; i < 6; i++) {
            HttpGet httpGet = new HttpGet("http://localhost:9000/router");
            // 获取响应
            HttpResponse response = httpclient.execute(httpGet);
            // 根据 响应解析出字符串
            System.out.println(EntityUtils.toString(response.getEntity()));
        }
    }

}
